import {
	HTTP
} from '../../common/js/http.js'

import util from '../../common/js/util.js'

export class HomeModel extends HTTP {
	getHomeData() {
		let user = util.getStorage('user')
		console.log('userID:' + user.userID)
		console.log('neiID:' + user.neiID)
		return this.request({
			url: 'api/Home/GetHome',
			data: {
				userID: user.userID,
				neiID: user.neiID
			}
		})
	}
	
	isUser() {
		let EntraneUrl = '/pages/register/Entrance/Entrance';
		let AuthenticationUrl = '/pages/register/perfectUser/perfectUser';
		return new Promise((resolve, reject) => {
			uni.getStorage({
				key: 'user',
				success(res) {
					if (res.data.stand == -1) {
						reject(AuthenticationUrl)
					} else {
						resolve()
					}
				},
				fail() {
					reject(EntraneUrl)
				}
			})
		})
	}
}
